<!DOCTYPE html>
<html>
<head>
<script>
	var callSrvc = 1;
	function loadXMLDoc() {
		var xmlhttp;
		if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp = new XMLHttpRequest();
		} else {// code for IE6, IE5
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		setInterval(callSrvcFn, 2000);
		
		xmlhttp.onreadystatechange = function() {
			document.getElementById("myDiv").innerHTML = "Fail";
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				var obj = JSON.parse(xmlhttp.responseText);
				document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
				document.getElementById("myDiv").innerHTML = obj.purgd_cnt;
			}
			callSrvc = 1;
		}
		//xmlhttp.open("POST","demo_post.asp",true);
		//xmlhttp.send();
		function callSrvcFn()
		{
			if(callSrvc == 0){
				return;
			}
			xmlhttp.open("POST", "recCount", true);
			xmlhttp.setRequestHeader("Content-type",
					"application/x-www-form-urlencoded");
			xmlhttp.send("HELLO HOW ARE YOU?");//fname=Henry&lname=Ford");
			callSrvc = 0;
		}
		//xmlhttp.open("GET","demo_get2.asp?fname=Henry&lname=Ford",true);
		//xmlhttp.send();
	}
</script>
</head>
<body>

<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<div id="myDiv"></div>

</body>
</html>

